import mapboxgl from 'mapbox-gl';
const mapbox = {
  data(){
      return{
          map: null,
          mapCenter: [116.708463, 23.37102],
          marker: null,
          zoom: 9,
      }
  },
  // mounted() {
  //   this.initMap()
  // },
  methods: {
    initMap () {
      mapboxgl.accessToken = 'pk.eyJ1Ijoic25zcXNzIiwiYSI6ImNrZ2oxbWtqMTAzNnAyeXFwMDAzdmp2YTAifQ.AuaHmI9j-_VbOYxUSJACQw' // 申请的key
      var coordinates = document.getElementById('coordinates');
      // debugger
      this.map = new mapboxgl.Map({
        container: this.$refs.basicMapbox,
        style: 'mapbox://styles/mapbox/streets-v11',
        center: this.mapCenter, // 设置地图中心
        zoom: this.zoom,  // 设置地图比例
        // color: "#FFFFFF",
        // draggable: true
      })
      //注册点击事件
      this.map.on("click", function(e) {
        console.log("点击" + e);
      });
    }
  },
  
}

export default mapbox;